<template>
  <el-dialog title="选择门店&主题" :visible.sync="switchThemeVisible" :before-close="closeDialog" center @open="upload">
    <div class=""  v-for="(list,ind) in parcel" >
      <checkBox :item="list" ref="theme"></checkBox>
    </div>

    <div slot="footer" class="dialog-footer">
      <el-button type="primary" round @click="uploadTheme" class="button-certain ">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>

    import checkBox from '@/components/checkBox';
    export default {
        name: "chooseThemeDialog",
        props:['parcel','switchThemeVisible'],
        components:{checkBox},
        data(){
          return{
            checkedThemes:[],
            themeList:[]
          }
        },
        methods:{
          closeDialog(){

          },
          uploadTheme(){
            const data = [];
            const self =this;
            self.$refs['theme'].forEach((item)=>{
              data.push(item.getCheckedThemes());
            })
            console.log(data);
            this.$emit('upload',data);
          },

          upload(){
            this.themeList = this.parcel;
            this.themeList.forEach((item)=>{
              item.checkAll = false;
              item.checkedThemes
            })
          }
        }
    }
</script>

<style scoped>
  .button-certain {
    background: #FF679E;
    border-color:#FF679E;
    border-radius: 101px;
    font-family: PingFangSC-Regular;
    font-size: 14px;
    color: #FFFFFF;
    letter-spacing: 0;
    padding: 10px 30px;
  }
</style>
